package com.lfx.concurrent.queue;

import java.util.Random;

/**
 * @author 李逢喜
 * create 2021/7/22
 */
public class ProducerThread extends Thread{


    private final MyQueue myQueue;

    private final Random random=new Random();


    private int index=0;


    public ProducerThread(MyQueue myQueue){
        this.myQueue=myQueue;
    }

    @Override
    public void run() {
        while (true){
            String element="数据"+index;
            index++;
            myQueue.put(element);
//            try {
//                Thread.sleep(random.nextInt(10000));
//            } catch (InterruptedException e) {
//                e.printStackTrace();
//            }
        }
    }
}
